//
//  MainMenuViewController.m
//  PacIsBack
//
//  Created by Jérémy Brault on 14/12/09.
//  Copyright 2009 None. All rights reserved.
//

#import "MainMenuViewController.h"

#import "Game.h"
#import "CreditsViewController.h"

@implementation MainMenuViewController
@synthesize player;

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	[[self navigationController] setNavigationBarHidden:YES];
    [super viewDidLoad];
	[self setPlayer:[MusicController instance]];
	[[self player] playMusic:@"opening"];
	[self setTitle:@"Title screen"];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}

#pragma mark -
#pragma mark User interactions management

- (IBAction)newGame {
	Game* game = [[Game alloc] initGame];
	[[self player] stopMusic];
	[[self navigationController] pushViewController:[game controller] animated:YES];
	[game startGame];
	[game release];
}

- (IBAction) showCredits {
	CreditsViewController* credits = [[CreditsViewController alloc] initCredits];
	[[self navigationController] pushViewController:credits animated:YES];
	[credits release];
}

#pragma mark -
#pragma mark Memory management

- (void)dealloc {
	[self setPlayer:nil];
    [super dealloc];
}

@end
